import type * as Flight from "@/types/flight"
import { request } from "@/http/axios"

/**
 * 获取航空公司列表
 */
export function getCarriersApi(): Promise<Flight.CarrierListResponse> {
  return request<Flight.CarrierListResponse>({
    url: "/carriers",
    method: "get"
  })
}

/**
 * 获取出发地列表
 */
export function getDeparturesApi(): Promise<Flight.DepartureListResponse> {
  return request<Flight.DepartureListResponse>({
    url: "/departures",
    method: "get"
  })
}

/**
 * 获取目的地列表
 */
export function getDestinationsApi(): Promise<Flight.DestinationListResponse> {
  return request<Flight.DestinationListResponse>({
    url: "/destinations",
    method: "get"
  })
}

/**
 * 搜索航班
 */
export function searchFlightsApi(data: Flight.FlightQueryCondition): Promise<Flight.SimpleFlightQueryResponse> {
  return request<Flight.SimpleFlightQueryResponse>({
    url: "/flight",
    method: "post",
    data
  })
}

/**
 * 根据ID获取航班价格趋势
 */
export function getFlightPriceTrendApi(id: string): Promise<Flight.FlightPriceTrendResponse> {
  return request<Flight.FlightPriceTrendResponse>({
    url: `/flight-price/${id}`,
    method: "get"
  })
}
